package Java多线程技术.第3章.多生产多消费;

import java.util.ArrayList;
import java.util.List;

public class Box {
    private static List list = new ArrayList();


    public synchronized void push(){
        if (list.size() < 50){
            list.add("anyString");
            System.out.println("线程 "+Thread.currentThread().getName()+" size "+size());

        }
    }

    public synchronized int size() {
        return list.size();
    }

    public synchronized Object popFrist(){
        Object o = list.remove(0);
        System.out.println("线程 "+Thread.currentThread().getName()+" size "+size());
        return o;

    }


}
